package com.oa.dao.impl;

import java.sql.CallableStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.oa.dao.UserInfosDao;
import com.oa.pojo.UserInfos;

public class UserInfosDaoImpl extends CommonDao<UserInfos> implements UserInfosDao {

	@Override
	public UserInfos getInfos(String id) {
		String sql="{call userinfos(?)}";
		List<UserInfos> us=new ArrayList<UserInfos>();
		try {
			open_db();
			CallableStatement cs=conn.prepareCall(sql);
			cs.setString(1, id);
			rs=cs.executeQuery();
			while (rs.next()) {
				UserInfos u=new UserInfos();
				u.setUserId(rs.getInt("userId"));
				u.setUserName(rs.getString("userName"));
				u.setRoleName(rs.getString("roleName"));
				u.setDepartName(rs.getString("departName"));
				u.setMsgCount(rs.getInt("msgCount"));
				us.add(u);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			close_db();
		}
		return us.get(0);
	}



}
